package io.renren.modules.lucky.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.lucky.entity.AppUserScoreEntity;
import io.renren.modules.lucky.service.AppUserScoreService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;

/**
 * app端-用户-积分信息表
 *
 * @author chenshun
 * @email chenchen@ashacker.com
 * @date 2019-08-31 20:58:28
 */
@RestController
@RequestMapping("lucky/appuserscore")
public class AppUserScoreController {

    @Autowired
    private AppUserScoreService appUserScoreService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("lucky:appuserscore:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = appUserScoreService.queryPage(params);
        return R.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("lucky:appuserscore:info")
    public R info(@PathVariable("id") Integer id){
		AppUserScoreEntity appUserScore = appUserScoreService.getById(id);
        return R.ok().put("appuserscore", appUserScore);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("lucky:appuserscore:save")
    public R save(@RequestBody AppUserScoreEntity appUserScore){
		appUserScoreService.save(appUserScore);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("lucky:appuserscore:update")
    public R update(@RequestBody AppUserScoreEntity appUserScore){
		appUserScoreService.updateById(appUserScore);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("lucky:appuserscore:delete")
    public R delete(@RequestBody Integer[] ids){
		appUserScoreService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
